package com.frinder.base.db;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

/**
 * @ClassName ModelWrapper
 * @Author frinder
 * @Description 根据条件查询包装类
 * @Date 2019/1/21 10:57
 * @Version 1.0
 */
@Data
@NoArgsConstructor
public class ModelWrapper<T> {

    private int size = 10;

    private T target;

    private List<String> likeFields = Lists.newArrayList();

    private List<String> equalFields = Lists.newArrayList();

    private List<String> notEqualFields = Lists.newArrayList();

    /**
     * 使用 inFields & notInFields 时，
     * 即使前端 target 不需要其它属性，也务必使用“ "target":{} ”的方式，初始化 target，否则查询失效
     */
    private Map<String, List<Object>> inFields = Maps.newHashMap();

    private Map<String, List<Object>> notInFields = Maps.newHashMap();

    /**
     * 大于等于 & 小于等于
     */
    private Map<String, Integer> greaterThanFields = Maps.newHashMap();

    private Map<String, Integer> greaterThanOrEqualFields = Maps.newHashMap();

    private Map<String, Integer> lessThanFields = Maps.newHashMap();

    private Map<String, Integer> lessThanOrEqualFields = Maps.newHashMap();
}
